package com.feather.common.converter.simple.fieldassignment;

import java.lang.reflect.Field;

import com.feather.common.converter.FieldAssignment;
import com.feather.common.util.ClassUtil;

/**
 * @author flogyin
 */
public class StringArray_Boolean implements FieldAssignment {
	@Override
	public Object assign(Object value, Object obj, Field field) {
		Boolean b = null;
		String[] strArray = (String[]) value;
		if (strArray != null && strArray.length > 0) {
			b = Boolean.valueOf(strArray[0]);
		} else {
			if (boolean.class.getName().equals(field.getType().getName()))
				b = false;
		}

		ClassUtil.set(obj, field, b);
		return null;
	}
}
